# -*- coding: utf-8 -*-
"""
create by zhoubing  2017-9-24
last change 2017-9-24
"""
from django.contrib import admin
from apps.customers.models import CustomerInfo
from apps.app_setting.models import SysParam


class CustomerInfoAdmin(admin.ModelAdmin):
    list_display = ('customer_name', 'customer_mobile', 'customer_joindate')
    search_fields = ('customer_name', 'customer_joindate')

    def formfield_for_foreignkey(self, db_field, request, **kwargs):
        if db_field.name == "customer_source":
            kwargs["queryset"] = SysParam.objects.filter(param_value__startswith=1002)
        return super(CustomerInfoAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs)


admin.site.register(CustomerInfo, CustomerInfoAdmin)
